<?php

namespace APP\demo\index\M;

use Lib\PdoDb\PdoDb;

/**
 * Index  测试用例 MODEL 层
 * 
 * 主要用于创建新的项目时使用
 * 
 * @author: Xialj
 * @date: 2019-08-24 23:46:18
 * @version: v1.0   
 * @email: m17269@163.com
 */
class IndexModel extends PdoDb
{
    public function __construct()
    {
        // 调用父级加载相应的数据库，必须执行参数
        parent::__construct();
    }

    // 继承封装SQL
    public function test(){
        $sql = "SELECT * FROM `remoteTest` order by id desc";
        $this->query($sql);
        $res = $this->selectQueryResult_ASSOC();
        return $res;
    }

    // 继承封装SQL1
    public function test1(){
        $sql = "INSERT INTO `remoteTest` (`remoteName`, `ip`, `ct`) VALUES ('111', '222', '333');";
        $res = $this->query($sql);
        return $res;
    }

    // 继承封装SQL2
    public function test2(){
        $sql = "INSERT INTO `remoteTest` (`remoteName`, `ip`, `ct`) VALUES ('%s', '%s', '%s');";
        $res = $this->pretreatmentAndQuery($sql, 'ani', ['$tmp_data','--', time()]);
        return $res;
    }
}
